package com.action
{
	import com.resource.unit.ActionUnit;
	import com.stage.item.Player;
	import com.utils.time.TimerClock;
	
	public class ActionJump extends BaseAction
	{
		private var _firstSpeed:Number = -20;
		private var _secondSpeed:Number = -12;
		private var _num:int = 0; // 二段跳，三段跳...
		private var _numMax:int = 0;
		private var _moveDir:int = 0;
		private var _jumpDir:int = 0;
		public function ActionJump(player:Player, speed:Number = 0, num:int=2)
		{
			super(player);
			
			_speed = speed;
			_numMax = num;
			_type = JUMP;
		}
		
		public override function start(dir:int=1, moveDir:int=0):void{
			if(_num < _numMax){
				_player.view.isStop = false;
				_actFinish = false;
				_player.act = ActionUnit.JUMP;
				super.start(dir);
				if(_num == 0){
					_downSpeed = _firstSpeed;
				}else{
					_downSpeed = _secondSpeed;
				}
				if(moveDir == 0){
					_jumpDir = _player.dir;
				}else{
					_jumpDir = moveDir;
				}
			}
			_num++;
		}
		
		protected override function onLandGround():void{
			if(_actFinish){
				actionCallback();
			}
		}
		
		protected override function actionEnd(player:Player):void{
			_player.view.isStop = true;
			_actFinish = true;
		}
		
		protected override function enterFrame():void{
			_player.x += _speed * _moveDir;
			checkGround();
		}
		
		public override function end():void{
			super.end();
			_player.view.isStop = false;
		}
	}
}